import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author 甜圆
 * @version v1.0.1
 * @date 2025/10/10 16:57
 * @package PACKAGE_NAME
 * @copyright 甜圆
 */
public class Test1 {
    public static AtomicInteger stock = new AtomicInteger(1000000);

    static class StockRunnable implements Runnable {
        @Override
        public void run() {
            int oldVaalue;
            int newValue;
            do {
                oldVaalue = stock.get();
                newValue = stock.get() - 1;
             }while (!stock.compareAndSet(oldVaalue, newValue));
        }
    }
}
